package com.miniapp.api;

import com.github.vioao.wechat.Const;
import com.github.vioao.wechat.bean.response.BaseResponse;
import com.github.vioao.wechat.bean.response.component.wxa.GetAuditstatusResponse;
import com.github.vioao.wechat.bean.response.component.wxa.GetPageResponse;
import com.github.vioao.wechat.utils.Params;
import com.github.vioao.wechat.utils.client.HttpUtil;
import com.miniapp.api.response.MemberAuthResponse;

import java.util.Map;

/**
 * Created with IntelliJ IDEA.
 * User: linyuchi
 * Date: 2018/5/3
 * Time: 18:57
 * Description: No Description
 */
public class OpenApi {

    private static final String MEMBER_AUTH = Const.Uri.API_URI + "/wxa/memberauth";

    private static final String LATEST_AUDIT_STATUS = Const.Uri.API_URI + "/wxa/get_latest_auditstatus";

    /**
     * 获取微信用户为小程序体验者列表 <br>
     *
     * @param accessToken 第三方平台获取到的该小程序授权的authorizer_access_token
     */
    public static MemberAuthResponse getMemberList(String accessToken) {
        String data = String.format("{\"action\":\"%s\"}", "get_experiencer");
        Map<String, String> params = Params.create("access_token", accessToken).get();
        return HttpUtil.postJsonBean(MEMBER_AUTH, params, data, MemberAuthResponse.class);
    }
    public static GetAuditstatusResponse getLatestAuditStatus(String accessToken) {
        Map<String, String> params = Params.create("access_token", accessToken).get();
        return (GetAuditstatusResponse)HttpUtil.getJsonBean(LATEST_AUDIT_STATUS, params, GetAuditstatusResponse.class);
    }

}
